package com.tingyuge.thinking.spring.configuration.bean.definition;

import com.tingyuge.thinking.spring.ioc.overview.domain.User;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author xiaodao
 * @version 1.0
 * @date 2021/6/27
 */
public class BeanInstantiationDemo {
    public static void main(String[] args) {

        BeanFactory beanFactory = new ClassPathXmlApplicationContext("META-INF/bean-instantiation-context.xml");
        User bean = beanFactory.getBean("user-by-static-method", User.class);
        User userByInstanceMethod = beanFactory.getBean("user-by-instance-method", User.class);
        User userByFactoryBean = beanFactory.getBean("user-by-factory-bean", User.class);
        System.out.println(bean);
        System.out.println("实例方法:"+ userByInstanceMethod);
        System.out.println("factoryBean:"+ userByFactoryBean);
        System.out.println(bean==userByInstanceMethod);
    }
}
